/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package deatax.display.gui;

import java.awt.Color;
import java.awt.Component;
import java.awt.Graphics;
import java.awt.Insets;
import javax.swing.border.Border;

/**
 *
 * @author nrechten
 */
public class BevelBorder implements Border{
    boolean top, bottom, left, right;

    public static Color SHADOW_HIGH = new Color(255, 255, 255, 150);
    public static Color SHADOW_LOW = new Color(0, 0, 0, 30);

    public BevelBorder(boolean top, boolean bottom, boolean left, boolean right) {
        this.top = top;
        this.bottom = bottom;
        this.left = left;
        this.right = right;
    }

    public BevelBorder(boolean left, boolean right) {
        this.left = left;
        this.right = right;
    }

    public void paintBorder(Component c, Graphics g, int x, int y, int width, int height) {
        if(top){
            g.setColor(SHADOW_HIGH);
            g.drawLine(1, 1, width-1, 1);
            g.setColor(SHADOW_LOW);
            g.drawLine(0, 0, width-1, 0);
        }
        if(bottom){
            g.setColor(SHADOW_HIGH);
            g.drawLine(1, height-2, width-2, height-2);
            g.setColor(SHADOW_LOW);
            g.drawLine(0, height-1, width-1, height-1);
        }
        if(left){
            g.setColor(SHADOW_HIGH);
            g.drawLine(1, 1, 1, height-2);
            g.setColor(SHADOW_LOW);
            g.drawLine(0, 0, 0, height-1);
        }
        if(right){
            g.setColor(SHADOW_HIGH);
            g.drawLine(width-1, 1, width-1, height-2);
            g.setColor(SHADOW_LOW);
            g.drawLine(width-2, 0, width-2, height-1);
        }
    }

    public Insets getBorderInsets(Component c) {
        return new Insets(top?1:0,bottom?1:0,left?1:0,right?1:0);
    }

    public boolean isBorderOpaque() {
        return true;
    }


}
